<template>
	<!-- pages/member/point_detail/point_detail.wxml -->
	<view class="container">
		<view class="list">
			<view class="title">积分明细</view>
			<template v-if="nowList.total > 0">
				<template v-for="(item, index) in nowList.data">
					<view class="item flex-box">
						<view class="flex-grow-1">
							<view class="fs30 col10 pb10">{{ item.memo }}</view>
							<view class="fs24 col9">{{ item.createtime_text }}</view>
						</view>
						<view v-if="item.score > 0" class="point">+{{ item.score }}</view>
						<view v-else class="point">+{{ item.score }}</view>
					</view>
				</template>
				<u-loadmore :status="loadStatus" fontSize="24" line loading-text="努力加载中" loadmore-text="轻轻上拉"
					nomore-text="没有更多了" />
			</template>
			<template v-else>
				<u-empty mode="data" text="暂无数据" textSize="24" icon="/static/images/none-data.png">
				</u-empty>
			</template>
		</view>
	</view>
</template>

<script>
	// pages/member/point_detail/point_detail.js
	const app = getApp();

	const functions = require('../../../utils/functions.js');

	export default {
		data() {
			return {
				// 列表
				nowList: {
					total: 0,
					current_page: 0,
					last_page: 1,
					data: []
				},
				loadStatus: 'loadmore', //加载状态
			};
		}
		/**
		 * 生命周期函数--监听页面加载
		 */
		,
		onLoad: function(options) {
			this.initData();
		},
		/**
		 * 生命周期函数--监听页面初次渲染完成
		 */
		onReady: function() {},
		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow: function() {},
		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide: function() {},
		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload: function() {},
		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh: function() {
			uni.showNavigationBarLoading(); //在标题栏中显示加载

			var that = this; //模拟加载

			setTimeout(function() {
				that.initData();
				uni.stopPullDownRefresh(); //停止下拉刷新
			}, 1500);
		},
		/**
		 * 页面上拉触底事件的处理函数
		 */
		// onShareAppMessage: function () {
		// }
		onReachBottom: function() {
			if (this.nowList.current_page >= this.nowList.last_page) {
				// functions.toast('已加载到底部了');
				this.loadStatus = 'nomore';
				return false;
			} else {
				this.getnowList();
			}
		},
		/**
		 * 用户点击右上角分享
		 */
		methods: {
			// 获取列表信息
			getnowList: function() {
				var that = this;
				var json = {};
				json.page = Number(that.nowList.current_page) + 1;

				if (json.page > 1 && that.nowList.current_page >= that.nowList.last_page) {
					functions.toast('已加载到底部了');
					this.loadStatus = 'nomore';
					return false;
				}
				this.loadStatus = 'loading';
				functions.getAjaxList(that, '/api/xiluhouse/score/score_list', json, function(res) {
					var nowList = res.data;

					if (json.page > 1) {
						var now_nowList_data = that.nowList.data || [];
						var now_nowList_data = now_nowList_data.concat(nowList.data);
						nowList.data = now_nowList_data;
					}

					that.nowList=nowList
					
				});
			},

			// 获取所有可下拉刷新更新的数据
			initData: function() {
				var that = this;
				that.nowList.current_page= 0;
				
				that.getnowList();
			}
		}
	};
</script>
<style>
	/* pages/member/point_detail/point_detail.wxss */
	.container .title {
		padding-top: 27rpx;
	}

	.list {
		padding: 0 40rpx;
	}

	.item {
		height: 133rpx;
		border-bottom: 1px solid #e9e9e9;
	}

	.point {
		color: #fe5939;
		font-size: 30rpx;
	}
</style>
